import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:lesson1/home_children/un_keep_live_widget.dart';

///
/// 那时我们有梦
/// 关于文学
/// 关于爱情
/// 关于穿越世界的旅行
/// 如今我们深夜饮酒
/// 杯子碰到一起
/// 都是梦破碎的声音
///
class KeepLiveWidget extends StatefulWidget {
  const KeepLiveWidget({super.key});

  @override
  State<KeepLiveWidget> createState() => _KeepLiveWidgetState();
}

class _KeepLiveWidgetState extends State<KeepLiveWidget>
    with AutomaticKeepAliveClientMixin {
  @override
  void initState() {
    super.initState();
    debugPrint('_KeepLiveWidgetState我被创建了哦');
  }

  @override
  Widget build(BuildContext context) {
    return Column(children: [
      Expanded(
        child: ListView.separated(
          itemBuilder: (ctx, index) => TestItemWidget(
            index: index,
          ),
          separatorBuilder: (BuildContext context, int index) => Divider(),
          itemCount: 300,
        ),
      ),
    ]);
  }

  @override
  bool get wantKeepAlive => true;
}
